<!--拥有小孩列表-->
<script type="text/javascript">
	var kid_info;
	$(document).ready(function(){
		var args = new Object();
		ajax_call('kid', 'get', args, success_get_kid);
		$("#return_kid").click( function () {
			if ( $(".detail_kid").css('display') == 'none' ) {
				//回到userinfo
				$("#main").load('userinfo.html');
				$("#main").removeClass('main_height');
			} else {
				//回到list_kid
				show_list_kid();
			}
		});
	});
	
	//获取小孩信息的回调
	function success_get_kid(ret) {
		kid_info = ret;
		Utils.setCookie("kid_info", ret);
		show_list_kid();
	}
	
	//显示小孩列表
	function show_list_kid() {
		$(".list_kid").show();
		$(".detail_kid").css('display','none');
		$(".list_kid").html('');
		$.each( kid_info, function(i, kid){
			$(".list_kid").append("<div onclick='showDetailKid("+i+")'>小孩:"+ kid.name +"</div>");
		});
	}
	
	//显示小孩详细信息
	function show_detail_kid(kid) {
		var detail_kid_info = kid_info[kid];
		$(".detail_kid").html('');
		var detail_kid_html = "";
		detail_kid_html += "<div class='posfloatl'><img src='./img/style/boy_body.png' /></div>";
		detail_kid_html += "<div class='posfloatl'><div>";
		detail_kid_html += "<div class='font_size_18'>小孩名:"+ detail_kid_info.name +"</div>";
		detail_kid_html += "<div id='mood' class='posfloatl font_size_14'>mood:"+ detail_kid_info.mood +"</div>";
		detail_kid_html += "<div id='waywardness' class='posfloatl font_size_14'>waywardness:"+ detail_kid_info.waywardness +"</div>";
		detail_kid_html += "<div id='max_power' class='posfloatl font_size_14'>max_power:"+ detail_kid_info.max_power +"</div>";
		detail_kid_html += "<div id='now_power' class='posfloatl font_size_14'>now_power:"+ detail_kid_info.now_power +"</div>";
		detail_kid_html += "</div><div class='posclear'>";
		detail_kid_html += "<div onclick='kidFeed("+kid+")' class='posfloatl font_size_12'>喂饭</div>";
		detail_kid_html += "<div onclick='kidChat("+kid+")' class='posfloatl font_size_12'>谈心</div>";
		detail_kid_html += "<div onclick='kidBelehrung("+kid+")' class='posfloatl font_size_12'>训话</div>";
		detail_kid_html += "<div onclick='kidEncourage("+kid+")' class='posfloatl font_size_12'>给零用钱</div>";
		detail_kid_html += "</div>";
		detail_kid_html += "<div class='posclear'></div>";
		$(".detail_kid").append(detail_kid_html);
		$(".list_kid").css('display','none');
		$(".detail_kid").show();
	}
	
	//喂饭
	function kid_feed(kid) {
		var args = new Object();
		args.kid= kid;
		ajax_call('kid', 'feed', args, success_kid_feed);
	}
	
	//喂饭回调
	function success_kid_feed(ret) {
		$('#now_power').html("now_power:"+ret.now_power);
		$('#header_coin').html(ret.coin);
		alert(sprintf(LNG.FEED, ret.reduce_coin, ret.get_power));
	}
	
	//谈心
	function kid_chat(kid) {
		var args = new Object();
		args.kid = kid;
		ajax_call('kid', 'chat', args, success_kid_chat);
	}
	
	//谈心回调
	function success_kid_chat(ret) {
		$('#mood').html("mood:"+ret.mood);
		alert(sprintf(LNG.ADD_MOOD, ret.get_mood));
	}
	
	//训话
	function kid_belehrung(kid) {
		var args = new Object();
		args.kid = kid;
		ajax_call('kid', 'belehrung', args, success_kid_belehrung);
	}
	
	//训话回调
	function success_kid_belehrung(ret) {
		$('#mood').html("mood:"+ret.mood);
		$('#waywardness').html("waywardness:"+ret.waywardness);
		alert(sprintf(LNG.BELEHRUNG, ret.reduce_mood, ret.reduce_waywardness));
	}
	
	//零花钱
	function kid_encourage(kid) {
		var args = new Object();
		args.kid= kid;
		ajax_call('kid', 'encourage', args, success_kid_encourage);
	}
	
	//零花钱回调
	function success_kid_encourage(ret) {
		$('#mood').html("mood:"+ret.mood);
		$('#header_coin').html(ret.coin);
		$('#mood').html("mood:"+ret.mood);
		alert(sprintf(LNG.ENCOURAGE, ret.reduce_coin, ret.get_mood));
	}
</script>
<div id="list_kid_html">
	<input type='button' id='return_kid' value='返回' />
	<div class="detail_kid"></div>
	<div class="list_kid"></div>
</div>
